<!--
 * @Description: 
 * @version: 
 * @Author: liurui
 * @Date: 2024-02-05 14:46:13
 * @LastEditors: 
 * @LastEditTime: 2024-02-05 14:52:31
-->
<template>
    <div>

    </div>
</template>

<script setup lang="ts">
// 实现一个为接口添加一个新字段的类型。该类型接收三个参数，返回带有新字段的接口类型

type Test = { id: '1' };

type Result = AppendToObject<Test, 'value', 4>; // expected to be { id: '1', value: 4 }

type AppendToObject<T, K extends keyof any, V> = T & Record<K, V>;

let s: Result = {
    id: '1',
    value: 4
}
</script>

<style scoped>

</style>